﻿<?php
    class sscls_HTML
    {
        function __($com='')
        {
            global $main;
            if($com=='')
            {
                $com=Request::getRequest('com');    
            }
            File::import('com/'.$com.'/html.php');
            $html=$main->get($com.'_html');
            return $html;
            
        }
        
        
        function displaypagelink($object)
        {
            global $tmpl;
            $tmpl->addvalue('pagination',$object);
            $tmpl->loadtmpl('pagination');
        }
        
        
        function showcaptcha($name)
        {
            global $config;
            $form = '<img src="'. $config->live_site . 'com/user/assets/imagebuilder1.php?name='.$name.'" border="1"/>';
            return $form;
        }
        
        function removeEvilAttributes($tagSource){
            $stripAttrib = "' (class?javascript:?onclick?ondblclick?onmousedown?onmouseup?onmouseover?onmousemove?onmouseout?onkeypress?onkeydown?onkeyup?oncontextmenu)=\"(.*?)\"'i";
            $tagSource = stripslashes($tagSource);
            $tagSource = preg_replace($stripAttrib, '', $tagSource);
        return $tagSource;
        }

        function removeEvilTags($source) {
            $tagSource='';
            $stripAttrib = "' (class?javascript:?onclick?ondblclick?onmousedown?onmouseup?onmouseover?onmousemove?onmouseout?onkeypress?onkeydown?onkeyup?oncontextmenu)=\"(.*?)\"'i";
            $tagSource = stripslashes($tagSource);
            $tagSource = preg_replace($stripAttrib, '', $tagSource);
            
            $allowedTags = '<h1><h2><h3><h4><h5><h6><b><p><u><i><a><ol><ul><li><pre><hr><blockquote><table><tr><td><th><span><div><strong><tbody><sup><font>';
            $source = strip_tags($source, $allowedTags);
            return preg_replace('/<(.*?)>/ie', $tagSource, $source);
        }
		
	function clearTag($value, $word_nb = null) {
		 $value= preg_replace('/{([a-zA-Z0-9\-_]*)\s*(.*?)}/i', '', $value);
		 $value= str_replace( '&nbsp;', ' ', $value );
		 $value = htmlspecialchars( strip_tags($value) );
		 
		//  neu co word_nb va lon hon moi chay
		if ($word_nb) {
			$text_arr = explode(" ", $value);
			if ( count($text_arr) > intval($word_nb) ) {
				$value = implode(" ", array_slice($text_arr, 0, $word_nb)) .'...';
			}
		}
			 
		return $value;
		
	}


		function editer($name='content',$value='',$cols=80,$rows=15)
		{
			?>
			<script type="text/javascript" src="<?php echo SITELIVE ?>tmpl/default/editer/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
			<script type="text/javascript"> 
					// O2k7 skin
	tinyMCE.init({
		// General options
		mode : "exact",
		elements : "<?php echo $name ?>",
		theme : "advanced",
		skin : "o2k7",
		plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups,autosave",

		// Theme options
		theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
		theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
		theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
		theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,

		// Example content CSS (should be your site CSS)
		content_css : "css/content.css",

		// Drop lists for link/image/media/template dialogs
		template_external_list_url : "lists/template_list.js",
		external_link_list_url : "lists/link_list.js",
		external_image_list_url : "lists/image_list.js",
		media_external_list_url : "lists/media_list.js",

		// Replace values for the template plugin
		template_replace_values : {
			username : "Some User",
			staffid : "991234"
		}
	});
			</script>
			<textarea id="<?php echo $name ?>" name="<?php echo $name ?>" rows="<?php echo $rows ?>" cols="<?php echo $cols ?>" ><?php echo $value ?></textarea>
			<?php 
		}
        
        
    } 
?>
